package entity

import (
	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//GJSDR 贵金属导入
type GJSDR struct {
	ID     int     `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF   int     `gorm:"column:KHYF"`
	CPMC   string  `gorm:"column:CPMC;size:100"`
	CJJE   float64 `gorm:"column:CJJE"`
	KHJLGH string  `gorm:"column:KHJLGH;size:100"`
	KHJLXM string  `gorm:"column:KHJLXM;size:100"`
	ZSBL   float64 `gorm:"column:ZSBL"`
	ZSJE   float64 `gorm:"column:ZSJE"`
	KHMC   string  `gorm:"column:KHMC;size:100"`
	DRJG   string  `gorm:"column:DRJG;"`
}

//GjsAfterImport 导入后执行
func GjsAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	// err = tx.Exec("UPDATE T_BASE_YXFY_GJS SET EMID=B.ID "+
	// 	"FROM T_BASE_YXFY_GJS A INNER JOIN T_SysUser B ON A.KHJLGH=B.SysUserID "+
	// 	"WHERE KHYF=?", params["KHYF"]).Error
	// if err != nil {
	// 	return err
	// }
	prams := make([]interface{}, 1)
	prams[0] = params["KHYF"]
	tx.Exec("EXEC UP_BASE_YXFY_GJS_DTIP ?", prams...)
	return nil
}

//TableName 贵金属导入表
func (GJSDR) TableName() string {
	return "T_BASE_YXFY_GJS_DTIP"
}

//GJSDREF 返回结构体
func GJSDREF() base.EntityFunc {
	return func() interface{} {
		entity := GJSDR{}
		return &entity
	}
}

//GJSDRESF 返回结构体数组
func GJSDRESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []GJSDR
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("GJSDR", base.NewDefaultDao(GJSDREF(), GJSDRESF(), nil))
	base.SetAfterCallBack("GJSDR", GjsAfterImport)
}
